home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / RLaB 1.18c / manual / srand.tex < prev    next >
LaTeX Document  |  1994-04-27  |  1.3 KB  |  [TEXT/ttxt]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: srand.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[ttxt]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 73 72 61 6e 64 20 2d |\section|{srand -|
|00000010| 2d 2d 20 52 61 6e 64 6f | 6d 20 53 65 65 64 7d 0d |-- Rando|m Seed}.|
|00000020| 5c 6c 61 62 65 6c 7b 66 | 6e 3a 73 72 61 6e 64 7d |\label{f|n:srand}|
|00000030| 0d 5c 69 6e 64 65 78 7b | 73 72 61 6e 64 28 29 7d |.\index{|srand()}|
|00000040| 0d 5c 69 6e 64 65 78 7b | 72 61 6e 64 6f 6d 20 73 |.\index{|random s|
|00000050| 65 65 64 7d 0d 5c 69 6e | 64 65 78 7b 73 65 65 64 |eed}.\in|dex{seed|
|00000060| 21 73 65 74 74 69 6e 67 | 7d 0d 5c 62 65 67 69 6e |!setting|}.\begin|
|00000070| 7b 72 61 69 6c 7d 0d 52 | 61 6e 64 6f 6d 53 65 65 |{rail}.R|andomSee|
|00000080| 64 20 3a 20 27 73 72 61 | 6e 64 27 20 27 28 27 20 |d : 'sra|nd' '(' |
|00000090| 28 20 28 29 20 7c 20 53 | 63 61 6c 61 72 20 7c 20 |( () | S|calar | |
|000000a0| 22 63 6c 6f 63 6b 22 20 | 29 20 27 29 27 20 3b 0d |"clock" |) ')' ;.|
|000000b0| 5c 65 6e 64 7b 72 61 69 | 6c 7d 0d 0d 5c 76 65 72 |\end{rai|l}..\ver|
|000000c0| 62 2b 73 72 61 6e 64 2b | 20 69 73 20 75 73 65 64 |b+srand+| is used|
|000000d0| 20 74 6f 20 73 65 74 20 | 74 68 65 20 73 65 65 64 | to set |the seed|
|000000e0| 20 66 6f 72 20 74 68 65 | 20 72 61 6e 64 6f 6d 20 | for the| random |
|000000f0| 6e 75 6d 62 65 72 20 67 | 65 6e 65 72 61 74 6f 72 |number g|enerator|
|00000100| 0d 72 6f 75 74 69 6e 65 | 73 20 69 6e 20 5c 76 65 |.routine|s in \ve|
|00000110| 72 62 2b 72 61 6e 64 2b | 2e 20 20 57 69 74 68 20 |rb+rand+|. With |
|00000120| 6e 6f 20 61 72 67 75 6d | 65 6e 74 73 2c 20 5c 76 |no argum|ents, \v|
|00000130| 65 72 62 2b 73 72 61 6e | 64 2b 20 72 65 73 65 74 |erb+sran|d+ reset|
|00000140| 73 20 74 68 65 0d 73 65 | 65 64 20 76 61 6c 75 65 |s the.se|ed value|
|00000150| 20 74 6f 20 74 68 65 20 | 6c 61 73 74 20 76 61 6c | to the |last val|
|00000160| 75 65 20 77 68 69 63 68 | 20 77 61 73 20 73 65 74 |ue which| was set|
|00000170| 2c 20 6f 72 20 74 6f 20 | 24 31 24 2c 20 77 68 69 |, or to |$1$, whi|
|00000180| 63 68 20 69 73 20 74 68 | 65 0d 73 65 65 64 20 76 |ch is th|e.seed v|
|00000190| 61 6c 75 65 20 6f 6e 20 | 73 74 61 72 74 75 70 2c |alue on |startup,|
|000001a0| 20 69 66 20 69 74 20 68 | 61 73 6e 27 74 20 62 65 | if it h|asn't be|
|000001b0| 65 6e 20 73 65 74 20 73 | 69 6e 63 65 2e 20 20 49 |en set s|ince. I|
|000001c0| 66 20 61 20 73 63 61 6c | 61 72 0d 61 72 67 75 6d |f a scal|ar.argum|
|000001d0| 65 6e 74 20 69 73 20 70 | 72 6f 76 69 64 65 64 2c |ent is p|rovided,|
|000001e0| 20 69 74 20 62 65 63 6f | 6d 65 73 20 74 68 65 20 | it beco|mes the |
|000001f0| 6e 65 77 20 73 65 65 64 | 2e 20 20 49 66 20 74 68 |new seed|. If th|
|00000200| 65 20 73 74 72 69 6e 67 | 0d 5c 76 65 72 62 2b 22 |e string|.\verb+"|
|00000210| 63 6c 6f 63 6b 22 2b 20 | 69 73 20 75 73 65 64 20 |clock"+ |is used |
|00000220| 61 73 20 74 68 65 20 61 | 72 67 75 6d 65 6e 74 2c |as the a|rgument,|
|00000230| 20 74 68 65 20 73 65 65 | 64 20 69 73 20 73 65 74 | the see|d is set|
|00000240| 20 66 72 6f 6d 20 74 68 | 65 0d 69 6e 74 65 72 6e | from th|e.intern|
|00000250| 61 6c 20 63 6c 6f 63 6b | 2e 20 20 54 68 65 20 6c |al clock|. The l|
|00000260| 61 74 74 65 72 20 6d 65 | 74 68 6f 64 20 77 69 6c |atter me|thod wil|
|00000270| 6c 20 70 72 6f 76 69 64 | 65 20 75 6e 69 71 75 65 |l provid|e unique|
|00000280| 20 76 61 6c 75 65 73 2e | 0d 0d 0d 5c 70 61 72 61 | values.|...\para|
|00000290| 67 72 61 70 68 7b 45 78 | 61 6d 70 6c 65 7d 0d 5c |graph{Ex|ample}.\|
|000002a0| 69 6e 64 65 78 7b 65 78 | 61 6d 70 6c 65 20 6f 66 |index{ex|ample of|
|000002b0| 20 73 72 61 6e 64 28 29 | 7d 0d 5c 69 6e 64 65 78 | srand()|}.\index|
|000002c0| 7b 73 72 61 6e 64 28 29 | 21 65 78 61 6d 70 6c 65 |{srand()|!example|
|000002d0| 7d 0d 5c 62 65 67 69 6e | 7b 76 65 72 62 61 74 69 |}.\begin|{verbati|
|000002e0| 6d 7d 0d 3e 20 72 61 6e | 64 28 32 2c 34 29 0d 20 |m}.> ran|d(2,4). |
|000002f0| 20 20 20 20 20 20 20 31 | 20 20 20 20 20 20 30 2e | 1| 0.|
|00000300| 36 34 37 20 20 20 20 20 | 30 2e 30 33 36 39 20 20 |647 |0.0369 |
|00000310| 20 20 20 20 30 2e 36 36 | 35 20 20 0d 20 20 20 20 | 0.66|5 . |
|00000320| 30 2e 39 37 35 20 20 20 | 20 20 20 30 2e 33 33 33 |0.975 | 0.333|
|00000330| 20 20 20 20 20 20 30 2e | 31 36 32 20 20 20 20 20 | 0.|162 |
|00000340| 30 2e 30 38 34 37 20 20 | 0d 3e 20 72 61 6e 64 28 |0.0847 |.> rand(|
|00000350| 32 2c 34 29 0d 20 20 20 | 20 30 2e 32 30 34 20 20 |2,4). | 0.204 |
|00000360| 20 20 20 20 30 2e 36 35 | 35 20 20 20 20 20 20 20 | 0.65|5 |
|00000370| 30 2e 39 31 20 20 20 20 | 20 20 30 2e 32 39 39 20 |0.91 | 0.299 |
|00000380| 20 0d 20 20 20 20 30 2e | 31 36 37 20 20 20 20 20 | . 0.|167 |
|00000390| 20 30 2e 31 32 39 20 20 | 20 20 20 20 30 2e 31 31 | 0.129 | 0.11|
|000003a0| 32 20 20 20 20 20 20 30 | 2e 32 36 35 0d 3e 20 73 |2 0|.265.> s|
|000003b0| 72 61 6e 64 28 31 29 3b | 0d 3e 20 2f 2f 20 52 65 |rand(1);|.> // Re|
|000003c0| 73 65 74 20 74 68 65 20 | 73 65 65 64 2e 0d 3e 20 |set the |seed..> |
|000003d0| 72 61 6e 64 28 32 2c 34 | 29 0d 20 20 20 20 20 20 |rand(2,4|). |
|000003e0| 20 20 31 20 20 20 20 20 | 20 30 2e 36 34 37 20 20 | 1 | 0.647 |
|000003f0| 20 20 20 30 2e 30 33 36 | 39 20 20 20 20 20 20 30 | 0.036|9 0|
|00000400| 2e 36 36 35 20 20 0d 20 | 20 20 20 30 2e 39 37 35 |.665 . | 0.975|
|00000410| 20 20 20 20 20 20 30 2e | 33 33 33 20 20 20 20 20 | 0.|333 |
|00000420| 20 30 2e 31 36 32 20 20 | 20 20 20 30 2e 30 38 34 | 0.162 | 0.084|
|00000430| 37 20 20 0d 3e 20 73 72 | 61 6e 64 28 22 63 6c 6f |7 .> sr|and("clo|
|00000440| 63 6b 22 29 0d 20 20 20 | 20 20 20 20 20 31 0d 3e |ck"). | 1.>|
|00000450| 20 72 61 6e 64 28 32 2c | 34 29 0d 20 20 20 20 30 | rand(2,|4). 0|
|00000460| 2e 33 36 36 20 20 20 20 | 20 20 30 2e 38 30 33 20 |.366 | 0.803 |
|00000470| 20 20 20 20 20 20 30 2e | 33 34 20 20 20 20 20 30 | 0.|34 0|
|00000480| 2e 30 31 39 32 20 20 0d | 20 20 20 20 30 2e 33 37 |.0192 .| 0.37|
|00000490| 32 20 20 20 20 20 20 20 | 30 2e 35 31 20 20 20 20 |2 |0.51 |
|000004a0| 20 20 30 2e 33 36 32 20 | 20 20 20 20 20 30 2e 35 | 0.362 | 0.5|
|000004b0| 37 35 20 20 0d 5c 65 6e | 64 7b 76 65 72 62 61 74 |75 .\en|d{verbat|
|000004c0| 69 6d 7d 0d 0d 53 65 65 | 20 61 6c 73 6f 3a 20 50 |im}..See| also: P|
|000004d0| 61 67 65 7e 5c 70 61 67 | 65 72 65 66 7b 66 6e 3a |age~\pag|eref{fn:|
|000004e0| 72 61 6e 64 7d 20 5c 76 | 65 72 62 2b 72 61 6e 64 |rand} \v|erb+rand|
|000004f0| 28 29 2b 2e 0d 0d 5c 6e | 65 77 70 61 67 65 0d 0d |()+...\n|ewpage..|
|00000500| 0d | |. | |
+--------+-------------------------+-------------------------+--------+--------+